<?php
/**
 * iBootstrap.php
 * @author qqinxl
 * Mon Oct 29 14:35:24 GMT 2007
 * 
 * @category  iQin
 * @package  
 * @copyright  Copyright (c) qqinxl
 */
/**
 * iBootstrap
 * @category  
 * @package   
 * @copyright  Copyright (c) qqinxl
 */
class iBootstrap {
		
	/**
     * _instance
     *
     * @static
     * @var iBootstrap
     * @access private
     */
	private static $_instance = null;

	/**
     * _log 
     * 
     * @var Zend_Log
     * @access private
     */
	private $_log = null;
	

	/**
     * getInstance 
     * 
     * @static
     * @access private
     * @return iBootstrap
     */
	public static function getInstance() {
		$className = __CLASS__;
		if (!(self::$_instance instanceof self)) {
			try{
				self::$_instance = new $className;
				Zend_Loader::registerAutoload();
				
				$config = new Zend_Config_Xml(CONFIG_FILE,null,true);				
				Zend_Registry::set('config', $config);				
				
				Bootstrap_SetupDate::build();
				Bootstrap_Cache::build();
				Bootstrap_Log::build();
			}catch (Exception $e) {
				throw $e;
			}
		}
		return self::$_instance;
	}
	
	/**
     * _buildLog
     *
     * 构造 Log对象，并缓存
     * 
     * @access public
     * @return Zend_Log
     */
	public function getLogWtiter(){		
		return Zend_Registry::get('log');
	}
	
	
	/**
     * run
     *
     * 运行 
     * 
     * @access private
     * @return void
     */
	public function run() {
		Bootstrap_Session::build();
		Bootstrap_DbAdapter::build();
		Bootstrap_FrontCtrl::build();
		Bootstrap_View::build();
		Bootstrap_Translator::build();
		Zend_Controller_Front::getInstance()->dispatch();
	}
}
